package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

/**
 * 获取注解中的参数
 */
public class ReflectDemo8 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Method method = cls.getMethod("sayHello");
        if(method.isAnnotationPresent(AutoRunMethod.class)){
            //获取该方法上的注解@AutoRunMethod
            AutoRunMethod arm = method.getAnnotation(AutoRunMethod.class);
            //通过注解对象获取value参数的值
            int value = arm.value();
            System.out.println(value);
        }
    }
}
